package libaryinterface.user;

import libaryinterface.interfaceutils.MyDialogDemo;
import service.UserService;
import service.impl.UserServiceImpl;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//确认删除的弹窗
public class UserIsDeleteInterface  extends JFrame {
    JFrame f1;
    JPanel p1;
    JButton b1,b2;
    JLabel l1;
    public UserIsDeleteInterface(String account)
    {
        Font f = new Font("黑体",Font.PLAIN,30);
        f1 = new JFrame("删除警告");
        p1=new JPanel();
        b1=new JButton("是");
        b2=new JButton("否");
        l1=new JLabel("确认删除？");

        p1.setLayout(null);
        l1.setBounds(200,95,900,60);
        l1.setFont(f);
        b1.setBounds(180,180,80,65);
        b1.setFont(f);
        b1.setForeground(Color.RED);
        b2.setFont(f);
        b2.setBounds(300,180,80,65);

        f1.add(p1);
        p1.add(b1);
        p1.add(b2);
        p1.add(l1);

        f1.setVisible(true);
        f1.setBounds(600,250,600,400);
        //是
        b1.addActionListener(new ActionListener() {
            UserService userService = new UserServiceImpl();
            @Override
            public void actionPerformed(ActionEvent e) {
                //删除用户
                boolean flag = userService.deleteUser1(account);
                if(flag){
                    new MyDialogDemo("删除成功!");
                }
                f1.dispose();
            }
        });
        //否
        b2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                f1.dispose();
            }
        });
    }

}
